package comparators;

import java.util.Comparator;

import enumerations.AttributesEnum;

import model.SummaryGenericScenarie;

public class SummaryGenericScenarieComparator implements Comparator<SummaryGenericScenarie> {

	@Override
	public int compare(SummaryGenericScenarie o1, SummaryGenericScenarie o2) {

		if (o1.getAttribute().equals(AttributesEnum.FUNCTIONALITY.name()) && !o2.getAttribute().equals(AttributesEnum.FUNCTIONALITY.name())) {
			return -1;
		} else if (o2.getAttribute().equals(AttributesEnum.FUNCTIONALITY.name()) && !o1.getAttribute().equals(AttributesEnum.FUNCTIONALITY.name())) {
			return 1;
		} else if (o1.getAttribute().equals(AttributesEnum.FUNCTIONALITY.name()) && o2.getAttribute().equals(AttributesEnum.FUNCTIONALITY.name())) {
			if (o1.getCluster() == o2.getCluster())
				return o1.getScenarie().compareTo(o2.getScenarie());
			else if (o1.getCluster() > o2.getCluster())
				return 1;
			else
				return -1;
		} else {
			return o1.getAttribute().toString().compareTo(o2.getAttribute().toString());
		}

	}

}
